package com.woniuxy.micromallserver.ordermag.controller;

import com.woniuxy.common.bean.ResultMsg;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

/**
 * @author unreleased
 * @date 2021/1/22 11:07
 */
@RestController
@RequestMapping("/admin")
public class SystemController {
    @RequestMapping("/login")
    public ResultMsg login(String username, String password){
        HashMap<String,String> hashMap = new HashMap<>();
        hashMap.put("token","admin-token");
        return new ResultMsg().setCode(20000).setData(hashMap);
    }
    @RequestMapping("/info")
    public ResultMsg info(String username, String password){
        List<String> roles = Arrays.asList("admin");
        UserInfo info = new UserInfo().setAvatar("img").setIntroduction("test").setName("张三").setRoles(roles);
        return new ResultMsg().setCode(20000).setData(info);
    }
    @Data
    @Accessors(chain = true)
    class UserInfo implements Serializable {
        private List<String> roles;
        private String introduction;
        private String avatar;
        private String name;
    }

}
